<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich" 
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <ui:composition>
        <style type="text/css">
            .inputstype{
                width: 175px !important;
            }
            .pic{
                margin-bottom: -4px;
                margin-right: -2px;
                border:none;
                width:20px;
                height:20px;
            }
            .col1{
                width:80px;
            }
            .col2{
            }
            .col3{
                width:100px;
            }
        </style>
        <script type="text/javascript">
            javascript:window.history.forward(1);
        </script>
        <script type="text/javascript">
            function showProj() {
                window.open("./pubinfo/projList.jsf", "项目列表", "height=1024,width=800,toolbar=no,menubar=no,scrollbars=no");
            }
            function updateProjSelect(code, name) {
                document.getElementById('costProof:projCode').value = code;
                document.getElementById('costProof:projName').value = name;
            }
        </script>
        <h:body>
            <h:form id="costProof">
                <rich:panel styleClass="content-hight">
                    <rich:messages globalOnly="true"/>
                    <h:panelGrid columns="4">
                        <h:outputLabel value="单据状态:"/>
                        <h:panelGroup>
                            <h:outputText value="已提交等待审核"  rendered="#{proof.exp.numberStatus eq '0'}" style="color:green"/>
                            <h:outputText value="未提交" rendered="#{proof.exp.numberStatus eq '1'}" style="color:red"/>
                            <h:outputText value="审核通过等待支付"  rendered="#{proof.exp.numberStatus eq '2'}" style="color:blue"/>
                            <h:outputText value="退回修改"  rendered="#{proof.exp.numberStatus eq '3'}" style="color:red"/>
                            <h:outputText value="确认支付"  rendered="#{proof.exp.numberStatus eq '4'}" style="color:blue"/>
                            <h:outputText value="撤单"  rendered="#{proof.exp.numberStatus eq '5'}" style="color:red"/>
                            <h:outputText value="支付完毕"  rendered="#{proof.exp.numberStatus eq '6'}" style="color:blue"/>
                        </h:panelGroup>
                        <h:outputLabel value="审核信息：" rendered="#{not empty proof.exp.checkInfo}" style="margin-left: 50px;"/>
                        <h:outputText value="#{proof.exp.checkInfo}"/>
                    </h:panelGrid>
                    <rich:toolbar itemSeparator="grida">
                        <rich:toolbarGroup>

                            <h:commandLink  action="#{proof.add}"
                                            disabled="#{proof.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/create_doc.gif" styleClass="pic" title="新增"/>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.checkandRep}"
                                            actionListener="#{proof.clearQueryResult}"
                                            disabled="#{!proof.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/save.gif" styleClass="pic" title="保存"/>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.update}" style=" margin: 1px;"
                                            disabled="#{proof.editStatus || (proof.exp.numberStatus != '1' and proof.exp.numberStatus != '3')}">
                                <h:graphicImage value="./images/edit.gif" styleClass="pic" title="修改"/>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.delete}"
                                            actionListener="#{proof.clearQueryResult}" style=" margin: 1px;"
                                            disabled="#{proof.editStatus || (proof.exp.numberStatus != '1' and proof.exp.numberStatus != '3')}">
                                <h:graphicImage value="./images/delete.gif" styleClass="pic" title="删除"/>
                            </h:commandLink>

                            <h:commandLink action="#{proof.cancel}"
                                            style=" margin: 1px;text-decoration: none;"
                                            immediate="true"
                                            disabled="#{!proof.editStatus}">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:graphicImage value="./images/cancel.png" styleClass="pic"/>
                                    <h:outputLabel value="取消" />
                                </h:panelGroup>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.submitBill}"
                                            actionListener="#{proof.clearQueryResult}" style=" margin: 1px;text-decoration: none;"
                                            disabled="#{proof.submitOrNot || proof.editStatus || proof.exp.numberStatus != '1'}">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:graphicImage value="./images/submit.png" styleClass="pic"/>
                                    <h:outputLabel value="提交" />
                                </h:panelGroup>
                            </h:commandLink>

                            <h:commandLink   action="#{proof.rescind}"
                                             actionListener="#{proof.clearQueryResult}"
                                             style=" margin: 1px;text-decoration: none;"
                                             disabled="#{proof.editStatus || proof.exp.numberStatus != '0'}">
                                <h:panelGroup style="white-space: nowrap;">
                                    <h:graphicImage value="./images/repeat.png" styleClass="pic"/>
                                    <h:outputLabel value="撤单" />
                                </h:panelGroup>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.getFirst}"
                                            disabled="#{proof.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_first.gif" styleClass="pic" title="首张"/>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.previouse}"
                                            disabled="#{proof.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_up.gif" styleClass="pic" title="上张"/>
                            </h:commandLink>

                            <h:commandLink   action="#{proof.next}"
                                             disabled="#{proof.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_down.gif" styleClass="pic" title="下张"/>
                            </h:commandLink>

                            <h:commandLink  action="#{proof.getLast}"
                                            disabled="#{proof.editStatus}" style=" margin: 1px;">
                                <h:graphicImage value="./images/btn_page_end.gif" styleClass="pic" title="末张"/>
                            </h:commandLink>

                            <a4j:commandLink render="loanPdf" execute="@form" style=" margin: 1px;"
                                              oncomplete="#{rich:component('voucherPanel')}.show()"
                                              disabled="#{proof.editStatus or empty proof.exp.number}">
                                <h:graphicImage value="./images/print.gif" styleClass="pic" title="打印"/>
                            </a4j:commandLink>                       

                        </rich:toolbarGroup>
                    </rich:toolbar>
                    <p style="text-align:center;font-family:黑体;font-weight:bold;font-size: 20px !important;" >支 出 证 明 单</p>
                    <hr style="border:1px dashed;"/>
                    <h:panelGrid columns="6" border="0" id="mainform1"  style="width:100%;text-align:left;"
                                 columnClasses="col1,col2,clo2,col3,col2,clo2">
                        <h:outputLabel value="单据编号:" />
                        <h:inputText  id="number" disabled="true" size="28" value="#{proof.exp.number}"
                                      required="true" requiredMessage="不能为空"/>
                        <rich:message for="number"/>

                        <h:outputLabel value="单据日期:" />
                        <rich:calendar id="billNumber"
                                       disabled="#{!proof.editStatus}"
                                       value="#{proof.exp.numDate}"
                                       locale="zh_CN"
                                       popup="true"
                                       datePattern="yyyy-MM-dd"
                                       showApplyButton="false"
                                       inputClass="inputstype"
                                       required="true" requiredMessage="不能为空">
                        </rich:calendar>
                        <rich:message for="billNumber"/>

                        <h:outputLabel value="预算项目:" />
                        <h:inputText  id="projName" disabled="#{!proof.editStatus}"  size="28"  value="#{proof.exp.project.finName}"
                                      onclick="#{rich:component('projPanel')}.show();"/>
                        <rich:message for="projName"/>

                        <h:outputLabel value="报销内容:"  />
                        <h:inputText  id="affair" size="28" disabled="#{!proof.editStatus}" 
                                      value="#{proof.exp.affair}" 
                                      required="true" requiredMessage="不能为空"
                                      validatorMessage="请勿超过30个字">
                            <f:validateLength maximum="30"/>
                        </h:inputText>
                        <rich:message for="affair"/>

                        <h:outputLabel value="用途："/>
                        <h:selectOneMenu value="#{proof.exp.feeItem.code}" disabled="#{!proof.editStatus}"
                                         required="true" requiredMessage="不能为空"
                                         id="feeItem" style="width:198px;">
                            <f:selectItems value="#{proof.feeItems}"/>
                        </h:selectOneMenu>
                        <rich:message for="feeItem"/>

                        <h:outputLabel value="支出部门:" />
                        <h:inputText  id="paydept"  disabled="#{!proof.editStatus}" value="#{proof.exp.payDept.name}"
                                      onclick="#{rich:component('deptPanel')}.show();" size="28"/>
                        <rich:message for="paydept"/>

                        <h:outputLabel value="经办人:" />
                        <h:selectOneMenu id="feePerson" value="#{proof.exp.feePer.cpsn_number}"
                                         style="width:198px;" disabled="#{!proof.editStatus}">
                            <f:selectItem itemValue="" itemLabel="-请选择-"/>
                            <f:selectItems value="#{proof.perli}" />
                        </h:selectOneMenu>
                        <rich:message for="feePerson"/>

                        <h:outputLabel value="费用总金额:"  />
                        <h:inputText id="total" size="28" disabled="#{!proof.editStatus}" value="#{proof.exp.total}"                                 
                                     required="true" requiredMessage="不能为空"
                                     converterMessage="请输入正确的数字。">
                            <a4j:ajax event="keyup" render="payable" />
                            <f:convertNumber type="double" pattern="###,##0.00"/>
                        </h:inputText>
                        <rich:message for="total" />

                        <h:outputLabel value="扣税金额:"  />
                        <h:inputText  id="taxAmount"  size="28" disabled="#{!proof.editStatus}" value="#{proof.exp.taxAmount}"
                                      converterMessage="请输入正确的数字。">
                            <a4j:ajax event="keyup" render="payable" />
                            <f:convertNumber type="double" pattern="###,##0.00"/>
                        </h:inputText>
                        <rich:message for="taxAmount" />

                        <h:outputLabel value="待付金额:"  />
                        <h:outputText id="payable" value="#{proof.exp.total - proof.exp.taxAmount}">
                            <f:convertNumber type="double" pattern="###,##0.00"/>
                        </h:outputText>
                        <rich:message for="payable"/>

                        <h:outputText value="支付方式:"/>
                        <h:selectOneMenu  id="payway" value="#{proof.exp.payStyle.code}"
                                          disabled="#{!proof.editStatus}" style="width:198px;"
                                          required="true" requiredMessage="不能为空">
                            <f:selectItems value="#{proof.payStylelist}" />
                        </h:selectOneMenu>
                        <rich:message for="payway"/>

                        <h:outputText value="附件张数:"/>
                        <h:inputText  id="affixAmount" size="28"
                                      value="#{proof.exp.affixAmount}"
                                      disabled="#{!proof.editStatus}"
                                      required="true" requiredMessage="不能为空"/>
                        <rich:message for="affixAmount"/>
                    </h:panelGrid>
                    
                    <hr style="border:1px dashed;"/>
                    <h:panelGrid columns="6" border="0" id="end" style="width:100%;text-align:left; "
                                 columnClasses="col1,col2,clo2,col3,col2,clo2">
                        <h:outputLabel value="部门名称:" />
                        <h:outputText  id="department"  value="#{proof.exp.dept.name}"  />
                        <rich:message for="department"/>
                        <h:outputLabel value="制 单 人:" />
                        <h:outputText  id="cpsn_name"   value="#{proof.exp.user.cpsn_name}"  />
                        <rich:message for="cpsn_name"/>
                    </h:panelGrid>
                </rich:panel>

            </h:form>
        </h:body>

        <rich:popupPanel id="voucherPanel" width="950" height="600">
            <f:facet name="header">
                <h:panelGroup>
                    <h:outputText value="打印"></h:outputText>
                </h:panelGroup>
            </f:facet>

            <f:facet name="controls">
                <h:outputLink value="#" onclick="#{rich:component('voucherPanel')}.hide();">关闭</h:outputLink>
            </f:facet>
            <a4j:mediaOutput element="object" cacheable="false" id="loanPdf"
                             uriAttribute="data"
                             standby="Loading Pdf..." mimeType="application/pdf"
                             type="application/pdf" style="width: 900px;height: 550px"
                             createContent="#{proof.process}" />
        </rich:popupPanel>
        <rich:popupPanel id="deptPanel" autosized="true">
            <f:facet name="header">
                <h:panelGroup>
                    <h:outputText value="费用承担部门"></h:outputText>
                </h:panelGroup>
            </f:facet>
            <f:facet name="controls">
                <h:outputLink value="#" onclick="#{rich:component('deptPanel')}.hide();">关闭</h:outputLink>
            </f:facet>
            <h:form>
                <rich:panel>
                    <h:panelGrid columns="2"  border="0" id="mainform">
                        <rich:tree value="#{departmentBean.rootNode}" var="idept"
                                   selectionType="ajax" toggleType="client"
                                   selectionChangeListener="#{proof.selected}"
                                   style="width:300px" render="paydept,feePerson">
                            <rich:treeNode>
                                <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                <rich:componentControl target="deptPanel" operation="hide" event="click"/>
                            </rich:treeNode>
                        </rich:tree>
                    </h:panelGrid>
                </rich:panel>
            </h:form>

            <f:facet name="footer">
                footer!
            </f:facet>

        </rich:popupPanel>

        <rich:popupPanel id="projPanel" autosized="true">
            <f:facet name="header">项目信息</f:facet>
            <f:facet name="controls">
                <h:outputLink value="#" onclick="#{rich:component('projPanel')}.hide();">关闭</h:outputLink>
            </f:facet>
            <h:form id="projList">
                <rich:dataTable id="editTable" value="#{proof.finProjModel}" rows="10"  var="pro"
                                onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                rowClasses="list-row-odd,list-row-even">
                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="预算项目编码"/>
                            </h:panelGroup>
                        </f:facet>
                        <a4j:commandLink id="Projlinks" action="#{proof.projSelected}"
                                         onclick="#{rich:component('projPanel')}.hide();"
                                         render="projName" >
                            <h:outputText value="#{pro.finCode}"/>
                        </a4j:commandLink>
                    </rich:column>

                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="预算项目名称"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{pro.finName}"/>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="备注"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{pro.memo}"/>
                    </rich:column>

                    <f:facet name="footer">
                        <rich:dataScroller id="ds"></rich:dataScroller>
                    </f:facet>
                </rich:dataTable>
            </h:form>
        </rich:popupPanel>

        <rich:popupPanel id="projQueryPanel" autosized="true">
            <f:facet name="header">项目信息</f:facet>
            <f:facet name="controls">
                <h:outputLink value="#" onclick="#{rich:component('projQueryPanel')}.hide();">关闭</h:outputLink>
            </f:facet>
            <h:form id="projQueryList">
                <rich:dataTable id="editTableQuery" value="#{proof.finProjModel}" rows="10"  var="pro"
                                onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                rowClasses="list-row-odd,list-row-even">
                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="预算项目编码"/>
                            </h:panelGroup>
                        </f:facet>
                        <a4j:commandLink id="ProjQuerylinks" action="#{proof.selectProjForQuery}"
                                         onclick="#{rich:component('projQueryPanel')}.hide();"
                                         render="proName" >
                            <h:outputText value="#{pro.finCode}"/>
                        </a4j:commandLink>
                    </rich:column>

                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="预算项目名称"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{pro.finName}"/>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:panelGroup>
                                <h:outputText value="备注"/>
                            </h:panelGroup>
                        </f:facet>
                        <h:outputText value="#{pro.memo}"/>
                    </rich:column>

                    <f:facet name="footer">
                        <rich:dataScroller id="ds"></rich:dataScroller>
                    </f:facet>
                </rich:dataTable>
            </h:form>
        </rich:popupPanel>

    </ui:composition>
</html>
